﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class LandschaftstexturEbene
    Inherits ObjektLandschaftsTextur

    Dim TexturLandschaft As Texture
    Public Sub New()
        ID = "EBENE"
        Landschaftsname = "Ebene"
        Deckung = 1
        Tarnung = False
        KP = -1

        Ausrichtungslandschaften = New String() {}

        If My.Settings.draw3D Then
            Ini3D()
        End If
        Select Case My.Settings.TerrainStyle
            Case TerrainStyle.CommanderWars2, TerrainStyle.AdvanceWarsDC
                TexturenLaden(New String() {"EBENE", "EBENE+0", "EBENE+1", "EBENE+3", "EBENE+7", "EBENE+8", "EBENE+9", "EBENE+10", "EBENE+11", "EBENE+18", "EBENE+19", "EBENE+20", "EBENE+21", "EBENE+22", "EBENE+2", "EBENE+4", "EBENE+5", "EBENE+6", "EBENE+12", "EBENE+13", "EBENE+14", "EBENE+15", "EBENE+16", "EBENE+17"})
                Normal = 23
            Case Else
                TexturenLaden(New String() {"EBENE", "EBENE+0", "EBENE+1", "EBENE+2", "EBENE+3"})
                Normal = 4
        End Select
    End Sub

    Public Overrides Sub Ini3D()
        TexturLandschaft = Grafikengine.LoadTexture(My.Settings.Resourcenpfad + "Landschaften\Bilder\3D\" + My.Settings.TexturQuali + "\Wiese.bmp")
    End Sub


    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)
        Dim standardMatrix As Matrix = Grafikengine.Grafikkarte.Transform.World
        Grafikengine.Grafikkarte.Transform.World = p_MatCube
        'Mesh.Malen()

        Grafikengine.Grafikkarte.SetTexture(0, TexturLandschaft)
        'Grafikengine.Grafikkarte.VertexFormat = Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured.Format

        'Berechnen:
        Dim Farbe As Color = ObjektmarkiertesFeld.getFeldFarbe(Landschaft.KooX, Landschaft.KooY)
        'Grafikengine.Grafikkarte.RenderState.Lighting = True 'Es wird mit dem Ambient Licht gemalt, das will ich aber nicht dauernd verändern, obwohl es sogar wahrscheinlich möglich wäre..
        Dim cube(3) As CustomVertex.PositionColoredTextured
        cube(0) = New CustomVertex.PositionColoredTextured(0, 0, 0, Farbe.ToArgb, 0, 1)
        cube(1) = New CustomVertex.PositionColoredTextured(0, 0, 1, Farbe.ToArgb, 0, 0)
        cube(2) = New CustomVertex.PositionColoredTextured(1, 0, 0, Farbe.ToArgb, 1, 1)
        cube(3) = New CustomVertex.PositionColoredTextured(1, 0, 1, Farbe.ToArgb, 1, 0)


        'Anzeigen:
        Grafikengine.Grafikkarte.VertexFormat = CustomVertex.PositionColoredTextured.Format
        Dim M As New Material
        M.Emissive = Farbe
        Grafikengine.Grafikkarte.Material = M
        Grafikengine.Grafikkarte.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, cube)
        'Grafikengine.Grafikkarte.RenderState.ZBufferEnable = True

        'Mesh.Malen()
        'Wieder den Ursprungsstatus wiederherstellen..
        Grafikengine.Grafikkarte.Transform.World = standardMatrix
    End Sub

    Public Overrides Sub Tick()

    End Sub
End Class




















Public Class LandschaftstexturÖdland
    Inherits ObjektLandschaftsTextur


    Public Sub New()
        ID = "ÖDLAND"
        Landschaftsname = "Ödland"
        Deckung = 2
        Tarnung = False
        KP = -1
        TexturenLaden(New String() {"Ödland"})
        Normal = 0
        Ausrichtungslandschaften = New String() {}
    End Sub

    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)

    End Sub

    Public Overrides Sub Ini3D()

    End Sub

    Public Overrides Sub Tick()

    End Sub
End Class





















Public Class LandschaftstexturRuine
    Inherits ObjektLandschaftsTextur


    Public Sub New()
        ID = "RUINE"
        Landschaftsname = "Ruine"
        Deckung = 1
        Tarnung = True
        KP = -1
        TexturenLaden(New String() {"Ruine"})
        Normal = 0
        Ausrichtungslandschaften = New String() {}
    End Sub

    Public Overrides Sub Malen3D(ByVal p_MatCube As Microsoft.DirectX.Matrix, ByVal Landschaft As ObjektLandschaft)

    End Sub

    Public Overrides Sub Ini3D()

    End Sub

    Public Overrides Sub Tick()

    End Sub
End Class